package com.macrounion.atv.service.service.impl;

import com.macrounion.atv.service.dto.req.VirtualReqDto;
import com.macrounion.atv.service.entity.VirtualChannel;
import com.macrounion.atv.service.entity.ext.VirtualExt;
import com.macrounion.atv.service.mapper.VirtualChannelMapper;
import com.macrounion.atv.service.mapper.VirtualChannelMapperExt;
import com.macrounion.atv.service.service.ChannelService;
import com.macrounion.atv.service.service.VirtualChannelService;
import com.macrounion.base.service.entity.PageInfo;
import com.macrounion.base.service.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class VirtualChannelServiceImpl extends BaseServiceImpl<VirtualChannelMapper, VirtualChannel> implements VirtualChannelService {

    @Autowired
    private VirtualChannelMapperExt virtualMapperExt;
    @Autowired
    private ChannelService channelService;

    @Override
    public List<VirtualExt> getVirtualList(VirtualReqDto virtualReqDto) {
        return virtualMapperExt.getVirtualList(virtualReqDto);
    }

    @Override
    public int findCount(String deviceId, String virtualId, String channelCode) {
        return virtualMapperExt.findCount(deviceId,virtualId,channelCode);
    }

	@Override
	public List<VirtualChannel> getFxHasDeviceCodeAndChannelCode(String deviceCode, String channelCode) {
		return virtualMapperExt.getByFxLike(channelService.getFxKey(deviceCode, channelCode));
	}

    @Override
    public VirtualChannel getVirtual(String deviceId, String channelCode) {
        return virtualMapperExt.getVirtual(deviceId,channelCode);
    }

    @Override
    public List<VirtualChannel> getList() {
        VirtualChannel virtual=new VirtualChannel();
        virtual.setPageInfo(new PageInfo());
        return mapper.requestPage(virtual);
    }

    @Override
    public VirtualChannel saveFx(VirtualChannel virtual) {
        virtualMapperExt.saveFx(virtual);
        return mapper.selectByPrimaryKey(virtual.getId());
    }

    @Override
    public int batchUpdate(HashMap<String, Object> mapVirtual) {
        return virtualMapperExt.batchUpdate(mapVirtual);
    }

    @Override
    public List<VirtualChannel> getVirtualByDeviceId(String deviceId) {
        return virtualMapperExt.getVirtualByDeviceId(deviceId);
    }

	@Override
	public List<VirtualExt> getAll() {
		return virtualMapperExt.getAll();
	}
}